package linestrategy

import (
	"codejy/analysis/lineanalysis"
	"codejy/structdef"
)

// 定义策略
type ThrowErrorStrategy struct{}

// // 注册策略
func init() {
	RegisterStrategy(&ThrowErrorStrategy{})
}

// 判断
func (f *ThrowErrorStrategy) getId() int {
	return lineanalysis.Throw
}
func (f *ThrowErrorStrategy) Execute(threadStore *structdef.ThreadStore) {
	//截取Throw(xx) 中的xx
	content := threadStore.Code.LineContent
	content = content[6 : len(content)-1]
	//添加到错误信息中
	threadStore.ErrorMsg = content
	//判断是否有双引号，如果有，那么就去掉
	if content[0] == '"' && content[len(content)-1] == '"' {
		content = content[1 : len(content)-1]
	}
	panic(content)
}
